package com.jm3.riscar3.commands;

import com.jm3.riscar3.core.Microcontroller;
import com.jm3.riscar3.interfaces.IAR3Command;
import com.jm3.riscar3.memory.Register;
import com.jm3.riscar3.memory.StatusRegister;


public class BRO implements IAR3Command {
	
	private final String OpCode = "10011";
	private StatusRegister SR;
	private Register PC;
	private Register[] Registers;

	
	public BRO(Microcontroller mcu){
		this.SR = mcu.getCPU().getSR();
	    this.PC = mcu.getCPU().getPC();
	    this.Registers = mcu.getCPU().getGRegs();

	}
	
	@Override
	public void execute(String args) throws Exception {
		// TODO Auto-generated method stub
		
		if(SR.getOverflowFlag()){
			PC.writeRegister(Registers[7].readRegister());
			
		}
	
	}

	@Override
	public String getOpCode() {
		// TODO Auto-generated method stub
		return OpCode;
	}


}
